        <!--Body content-->
        <div id="content" class="clearfix">
            <div class="contentwrapper"><!--Content wrapper-->
                <div class="heading">
                    <h3>Tambah Barang</h3>                    
                    <div class="resBtnSearch">
                        <a href="#"><span class="icon16 icomoon-icon-search-3"></span></a>
                    </div>

                   <!-- <div class="search">

                        <form id="searchform" action="http://themes.suggeelson.com/supr/search.html">
                            <input type="text" id="tipue_search_input" class="top-search" placeholder="Search here ..." />
                            <input type="submit" id="tipue_search_button" class="search-btn" value=""/>
                        </form>
                
                    </div>
                    
                    <ul class="breadcrumb">
                        <li>You are here:</li>
                        <li>
                            <a href="#" class="tip" title="back to dashboard">
                                <span class="icon16 icomoon-icon-screen-2"></span>
                            </a> 
                            <span class="divider">
                                <span class="icon16 icomoon-icon-arrow-right-2"></span>
                            </span>
                        </li>
                        <li class="active">Forms</li>
                    </ul><!-- End search -->

                </div><!-- End .heading-->
    				
                <!-- Build page from here: Usual with <div class="row-fluid"></div> -->

                    <div class="row-fluid">

                        <div class="span6">

                            <div class="box">

                                <div class="title">

                                    <h4> 
                                        <span>Kolom Tambah Barang</span>
                                    </h4>
                                    
                                </div>
                                <div class="content">
                                    <form class="form-horizontal" id="form-bahan" action="<?php echo base_url();?>barang/action" method="POST">
									<div class="group-form">
						<div class="group-header">
                            <h4>Data Barang</h4>
                        </div>
                                        <div class="form-row row-fluid"> 
                                            <div class="span12">
                                                <div class="row-fluid">
                                                    <label class="form-label span4" for="placeholder">ID Barang</label>
                                                    <input class="span8" <?php echo $readonly;?> id="id_barang" name="id_barang" type="text" placeholder="ID Barang" value="<?php echo $data['id_barang'];?>"/>
                                                </div>
                                            </div>											
                                        </div>
                                        <div class="form-row row-fluid"> 
                                            <div class="span12">
                                                <div class="row-fluid">
                                                    <label class="form-label span4" for="placeholder">Nama Barang</label>
                                                    <input class="span8" id="nama_barang" name="nama_barang" type="text" placeholder="Nama Barang" value="<?php echo $data['nama_barang']?>" />
                                                </div>
                                            </div> 
                                        </div>

                                        <div class="form-row row-fluid">
                                            <div class="span12">
                                                <div class="row-fluid">
                                                    <label class="form-label span4" for="checkboxes">Kategori</label>
                                                    <div class="span8 controls">   
                                                        <select name="kategori">
<?php if($this->uri->segment(2) == "update"){?>
                                                            <option value="<?php echo $data['id_kategori_barang']; ?> " selected><?php echo $data['nama_kategori_barang']; ?></option>
<?php } ?>	
														<?php foreach($kategori as $row){?>
                                                            <option value="<?php echo $row->id_kategori_barang; ?>"><?php echo $row->nama_kategori_barang; ?></option>
														<?php } ?>
                                                        </select>
                                                    </div> 
                                                </div>
                                            </div> 
                                        </div>
									</div>
									<div class="group-form kebutuhan">
										<div class="group-header">
											<h4>Kebutuhan</h4>
										</div>
										<div class="form-row row-fluid" id="kebutuhan_0" hidden> 
                                            <div class="span12">
                                                <div class="row-fluid">
                                                    <label class="form-label span4" for="placeholder">Kebutuhan 1</label>
 													<div class="grid-inputs span8">
                                                        <input class="span7 text" name="nama_bahan[]" id="nama_bahan_0" type="text" placeholder="Nama Bahan">
                                                        <input class="span3 text" name="jumlah[]"  type="text" placeholder="Jumlah">
														<button id="hapus_kebutuhan" type="button" class="btn btn-danger btn-mini">Hapus</button>
                                                    </div>
                                                </div>
                                            </div> 
                                        </div>
<?php if($this->uri->segment(2) == "update"){
$no = 1000;
$n1 = 1;
foreach($kebutuhan as $row){
?>
						                <div class="form-row row-fluid" id="<?php echo "kebutuhan_".$no++;?>"> 
                                            <div class="span12">
                                                <div class="row-fluid">
                                                    <label class="form-label span4" for="placeholder">Kebutuhan <?php echo $n1++;?></label>
 													<div class="grid-inputs span8">
                                                        <input class="span7 text" name="nama_bahan[]" id="nama_bahan_1" type="text" placeholder="Nama Bahan" value="<? echo $row->nama_bahan;?>" readonly>
                                                        <input class="span3 text" name="jumlah[]"  type="text" placeholder="Jumlah" value="<? echo $row->jumlah_kebutuhan;?>" readonly>
														<button id="hapus_kebutuhan" type="button" class="btn btn-danger btn-mini">Hapus</button>
                                                    </div>
                                                </div>
                                            </div> 
                                        </div>
<?php }
} else{ ?>		
						                <div class="form-row row-fluid" id="kebutuhan_1"> 
                                            <div class="span12">
                                                <div class="row-fluid">
                                                    <label class="form-label span4" for="placeholder">Kebutuhan 1</label>
 													<div class="grid-inputs span8">
                                                        <input class="span7 text" name="nama_bahan[]" id="nama_bahan_1" type="text" placeholder="Nama Bahan">
                                                        <input class="span3 text" name="jumlah[]"  type="text" placeholder="Jumlah">
                                                    </div>
                                                </div>
                                            </div> 
                                        </div>
<?php } ?>											
										<div class="form-row row-fluid row_btn_kebutuhan"> 
                                            <div class="span12">
                                                <div class="row-fluid">
													<button type="button" class="btn pull-right" id="btn_kebutuhan">add</button>
                                                </div>
                                            </div> 
                                        </div>
										</div>
										<div class="group-form">
										<div class="group-header">
											<h4>Langkah Kerja</h4>
										</div>
                                        <div class="form-row row-fluid" id="langkah_0" hidden> 
                                            <div class="span12">
                                                <div class="row-fluid">
                                                    <label class="form-label span4" for="placeholder">Langkah 1</label>
                                                    <input class="span7" name="langkah[]" type="text" placeholder="Langkah kerja" value="<?php //echo $data['nama_barang']?>" />
													<button id="hapus_langkah" type="button" class="btn btn-danger btn-mini">Hapus</button>
                                                </div>
                                            </div> 
                                        </div>
<?php if($this->uri->segment(2) == "update"){
$no = 1000;
$n2 = 1;
foreach($langkah as $row){
?>

										<div class="form-row row-fluid" id="<?php echo "langkah_".$no++; ?> "> 
                                            <div class="span12">
                                                <div class="row-fluid">
                                                    <label class="form-label span4" for="placeholder">Langkah <?php echo $n2++;?></label>
                                                    <input class="span7" name="langkah[]" type="text" placeholder="Langkah kerja" value="<?php echo $row->nama_langkah_kerja; ?>" readonly />
													<button type="button" class="btn btn-danger btn-mini" id="hapus_langkah">Hapus</button>
                                                </div>
                                            </div> 
                                        </div>
<?php }
} else{ ?>										
										  <div class="form-row row-fluid" id="langkah_1"> 
                                            <div class="span12">
                                                <div class="row-fluid">
                                                    <label class="form-label span4" for="placeholder">Langkah 1</label>
                                                    <input class="span7" name="langkah[]" type="text" placeholder="Langkah kerja" value="<?php //echo $data['nama_barang']?>" />
                                                </div>
                                            </div> 
                                        </div>
<?php } ?>										
										<div class="form-row row-fluid row_btn_langkah"> 
                                            <div class="span12">
                                                <div class="row-fluid">
													<button type="button" class="btn pull-right" id="btn_langkah">add</button>
                                                </div>
                                            </div> 
                                        </div>
										</div>
										<div class="form-actions">
                                           <button type="submit" class="btn btn-info" name="<?php echo $this->uri->segment(2);?>">Save changes</button>
                                           <button type="button" class="btn">Cancel</button>
                                        </div>
                                    </form>
                                </div>
                            </div><!-- End .box -->
                        </div><!-- End .span6 -->        											
				</div><!-- End .row-fluid -->
            </div><!-- End contentwrapper -->
        </div><!-- End #content -->

												<?php 
												$arrNamaBahan = array();
												foreach ($nama_bahan_gudang as $row){
												$arrNamaBahan[] = $row->nama_bahan;
												}
												?>
<script type="text/javascript">
//------------- JQuery Autocomplete -------------//
//    $(function() {
		var arrNamaBahan = <?php echo json_encode($arrNamaBahan); ?>;
		$("input").focus(function(){
		id = $(this).attr("id")
//		$(".row-fluid input").attr("id");
		//alert(id);
		
		console.log(id);
		
		$( "#"+id ).autocomplete({
			source: function( request, response ) {
			  var matcher = new RegExp( "^" + $.ui.autocomplete.escapeRegex( request.term ), "i" );
			  response( $.grep( arrNamaBahan, function( item ){
				  return matcher.test( item );
			  }) );
			}
		});
	});
//});
</script>
<script type="text/javascript">
		$('#hapus_kebutuhan').live('click', function () {
			var root = $(this).parent().parent().parent().parent();
			console.log(root);
			$(root).slideToggle(500,function(){
				$(root).remove();
			});
		})
		$('#hapus_langkah').live('click', function () {
			var root = $(this).parent().parent().parent();
			console.log(root);
			$(root).slideToggle(500,function(){
				$(root).remove();
			});
		})
</script>
<script type="text/javascript">
//$(document).ready(function() {
/*
$("#hapus_kebutuhan").click(function(){
		console.log($(this));
		$(this).parent().parent().parent().parent().remove();
});

$("#hapus_langkah").click(function(){
		console.log($(this));
		$(this).parent().parent().parent().remove();
	});
	*/
//});
</script>
<script type="text/javascript">
var counter = <?php if(isset($n1)) echo ($n1-1); else echo "1"; ?>;
//var counter = 1;
$("#btn_kebutuhan").click(function(){
//$("p:first").replaceWith("Hello world!");
	//counter = counter+1;
//	var nama = $( '#nama_bahan_'+ (counter-1) ).clone(true).removeAttr('value').attr('id','nama_bahan_'+counter);
//	var jumlah = $( '#jumlah_'+ (counter-1) ).clone(true).attr('id','jumlah_'+counter);
	
//	var content = '<div class="form-row row-fluid" id="kebutuhan_'+counter+'"> <div class="span12"><div class="row-fluid"><label class="form-label span4" for="placeholder">Kebutuhan '+counter+'</label><div class="grid-inputs span8 '+counter+'"></div></div></div></div>';
//    $(content).insertBefore('.row_btn_kebutuhan');
//	$( '#kebutuhan_0' ).clone(true).removeAttr('hidden').insertBefore('.row_btn_kebutuhan').find('#nama_bahan_0').attr('id','nama_bahan_'+ (counter+1));
	$( '#kebutuhan_0' ).clone(true).attr('id','kebutuhan_'+ (counter+1)).insertBefore('.row_btn_kebutuhan').slideToggle();
	$( '#kebutuhan_' + (counter+1) ).find('#nama_bahan_0').attr('id','nama_bahan_'+ (counter+1));
	console.log($( '#kebutuhan_' + (counter+1) ).find('label').html('Kebutuhan '+(counter+1)));
//	$( '#kebutuhan_' + (counter+1) ).find('#jumlah_0').attr('id','jumlah_'+ (counter+1));
//	nama.appendTo("."+counter);
//	jumlah.appendTo("."+counter);
	console.log(counter);
	counter = counter+1;
});
</script>
<script type="text/javascript">
//var c = 1;
var c = <?php if(isset($n1)) echo ($n1-1); else echo "1"; ?>;
$("#btn_langkah").click(function(){
	$( '#langkah_0' ).clone(true).attr('id','langkah_'+ (c+1)).insertBefore('.row_btn_langkah').slideToggle();
	$( '#langkah_' + (c+1) ).find('label').html('Langkah '+(c+1));
	console.log(c);
	c = c+1;
});
</script>
<script type="text/javascript">
    //--------------- Data tables ------------------//

	if($('table').hasClass('barangTable')){
		$('.barangTable').dataTable({
			"bJQueryUI": false,
			"bFilter": false,
			"bAutoWidth": false,
			"iDisplayLength": 5,
			"bLengthChange": false,
			"aoColumnDefs": [{ 
				"bSortable": false, "aTargets": [ 0, 1, 2, 3 ] 
			}],
		});
	}
	
/*
$(document).ready(function() {

	var oTable = $('.barangTable').dataTable({
			"bJQueryUI": false,
			"bFilter": false,
			"bAutoWidth": false,
			"iDisplayLength": 5,
			"bLengthChange": false,
			"aoColumnDefs": [{ 
				"bSortable": false, "aTargets": [ 0, 1, 2, 3 ] 
			}],
		});
	
	$('td', oTable.fnGetNodes()).editable( sites+'barang/tes', {
		"callback": function( sValue, y ) {
			var aPos = oTable.fnGetPosition( this );
			oTable.fnUpdate( sValue, aPos[0], aPos[1] );
		},
		"submitdata": function ( value, settings ) {
			return {
				"row_id": this.parentNode.getAttribute('id'),
				"column": oTable.fnGetPosition( this )[2]
			};
		},
		"height": "14px"
	} );
} );
*/	
</script>